precision mediump float;
uniform sampler2D u_texture0; //fire
uniform sampler2D u_texture1; //alpha
uniform sampler2D u_texture2; //displacement
uniform float offset;

varying vec2 v_uv; //Tex_coords_original
void main()
{
	vec2 Displacement_offset=texture2D(u_texture2, vec2(v_uv.x,v_uv.y+offset)).rg;
	//vec2 Tex_coords_displaced=v_uv+(0.4*offset-0.2)*Displacement_offset;
	vec2 Tex_coords_displaced=vec2(mix(v_uv.x,Displacement_offset.x,0.1),mix(v_uv.y,Displacement_offset.y,0.1));
	vec4 fire_color = texture2D (u_texture0, Tex_coords_displaced);
	vec4 AlphaValue = texture2D(u_texture1, v_uv);
	vec4 Color = fire_color * vec4(1.0, 1.0, 1.0, AlphaValue.r);
	//if(Color.a < 0.5)
		//discard;
	//else
		gl_FragColor = Color;
	//gl_FragColor = texture2D(u_texture2, v_uv);
}
